import 'dart:async';
import 'package:qgchat/bloc/blocProvider.dart';
import 'package:qgchat/common/class/websocket/index.dart';
import 'package:qgchat/common/global/global.dart';
import 'package:qgchat/http/models/socketModel.dart';

class MsgBloc implements BlocBase {
  
  // ##########  STREAMS  ##############

  /// 聊天列表
  StreamController _chat = StreamController<List<SocketModel>>.broadcast();
  Sink get _chatSink => _chat.sink;
  Stream get chatStream => _chat.stream;

  void dispose() {
    _chat.close();
  }

  // ##########  HANDLING  ##############

  /// socket
  WebSocket ws = Global.ws;
  /// 私聊列表
  List<SocketModel> chatList = [];

  MsgBloc() {
    /// 挂载私信回调方法
    // ws.listenMessageActions.add(_listenMessage);
  }

  /// 监听消息
  void _listenMessage(SocketModel data) {
    // chatList.add(data);
    // _chatSink.add(chatList);
  }
}
